package com.asd.netty.controller;

import com.asd.netty.Servcie.InformationService;
import com.asd.netty.entity.Information;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("information")
@CrossOrigin(origins = {},methods = {RequestMethod.POST,RequestMethod.OPTIONS,RequestMethod.GET})
public class InformationController {

    @Autowired
    private InformationService servicer;

    @GetMapping("/list")
    public Map InformationList(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "size", defaultValue = "10") Integer size) {
        PageRequest request = new PageRequest(page -1, size);
        Page<Information> informationPage = this.servicer.finfAll(request);
        Map map = new HashMap();
        map.put("informationPage", informationPage);
        map.put("currentPage",page);
        map.put("size",size);
        return map;
    }
}
